package com.foreveross.project.usercenterserver.common.utils;

import java.util.Random;
import java.util.UUID;


public class CodeUtils {

    /**
     * @Description:getUUID 获取去除“-”的UUID作为数据库中的code
     * @Param:
     * @Return:java.lang.String
     * @Author:Lin
     */
    public static String getUUID(){
        String code = UUID.randomUUID().toString();
        return code.replace("-","");
    }

    /**
     * 获取部署的路由上下文名称
     * @param code
     * @return
     */
    public static String getDeployApplicationName(String code) {
        return "nc_" + code + "_activity";
    }

    public static String setCode(){
    //生成唯一活动编码
    String str="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    Random random=new Random();
    StringBuffer sb=new StringBuffer();
        for(int i=0;i<6;i++){
            int number =random.nextInt(62);
            sb.append(str.charAt(number));
    }
    String activityCode = sb.toString();
        return activityCode;
    }

    /***
     * 生成全英文
     * @return
     */
    public static String getEnCode(){
        //生成唯一活动编码
        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        Integer length =11;
        Integer max = 53;
        for(int i=0;i<length;i++){
            int number =random.nextInt(max);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }




}
